package com.spar.openprojects.shared.rowmapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.spar.openprojects.shared.Member;
import com.spar.openprojects.shared.Project;
import com.sql.database.IRowMapper;

public class ProjectRowMapper implements IRowMapper {

	@Override
	public Project mapRow(ResultSet rs) throws SQLException {
		Project project = new Project();
		Member member = new Member();
		MemberRowMapper memberRowMapper = new MemberRowMapper();
		member = memberRowMapper.mapRow(rs);
		project.setMember(member);
		project.setId(rs.getInt("p.id"));
		project.setNumber(rs.getInt("p.number"));
		project.setDescription(rs.getString("p.description"));
		project.setExternalCostsOrdered(rs.getInt("sorder.sumOrder"));
		project.setExternalCosts(rs.getInt("p.external_costs"));
		project.setInternalDays(rs.getInt("p.internal_days"));
		return project;
	}

}
